using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "DataTemplate", menuName = "Data Template/Character Stats")]
public class CharacterData_SO : ScriptableObject
{
    [Header("Stats")]
    public int maxHealth;
    public int currentHealth;
    public int baseDefence;
    public int currentDefence;
    [Header("Kill")]
    public int killPoint;
    [Header("Level")]
    public int currentLevel;
    public int maxLevel;
    public int baseExp;
    public int currentExp;
    public float levelBuff;
    public float LevelUpMultiplier
    {
        get
        {
            return 1 + (currentLevel - 1) * levelBuff;
        }
    }
    public void UpdateExp(int point)
    {
        currentExp += point;
        if (currentExp >= baseExp)
        {
            LevelUp();
        }
    }

    private void LevelUp()
    {
        currentLevel = Mathf.Clamp(currentLevel + 1, 0, maxLevel);
        baseExp += (int)(baseExp * LevelUpMultiplier);

        maxHealth = (int)(maxHealth * LevelUpMultiplier);
        currentHealth = maxHealth;
        // 打开背包使用经验果实、击杀怪物升级时，更新状态栏
        InventoryManager.Instance.UpdateHPAndAtk(GameManager.Instance.playerStat.MaxHealth, GameManager.Instance.playerStat.attackData.minDamage, GameManager.Instance.playerStat.attackData.maxDamage);
    }
}
